﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<Style TargetType="TreeViewItem">
		<Setter Property="Padding" Value="3,4" />
		<Setter Property="Margin" Value="0" />
		<Setter Property="HorizontalContentAlignment" Value="Stretch" />
		<Setter Property="VerticalContentAlignment" Value="Stretch" />
		<Setter Property="Foreground" Value="{DynamicResource Black}" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="TreeViewItem">
					<Grid Background="Transparent">
						<Grid.ColumnDefinitions>
							<ColumnDefinition MinWidth="19" Width="Auto" />
							<ColumnDefinition Width="*" />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition />
						</Grid.RowDefinitions>
						<Border x:Name="Bd" Grid.ColumnSpan="2" Background="Transparent" BorderBrush="Transparent"
								BorderThickness="0" Margin="0,0,0,1" />
						<Border x:Name="PART_Header" Padding="{TemplateBinding Padding}" Grid.Column="1"
								Background="Transparent">
							<Border.CacheMode>
								<BitmapCache />
							</Border.CacheMode>
							<ContentPresenter ContentTemplate="{TemplateBinding HeaderTemplate}"
									Content="{TemplateBinding Header}"
									ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header"
									HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
									SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
						</Border>
						<ToggleButton x:Name="Expander" ClickMode="Press"
								IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
								SnapsToDevicePixels="True" Margin="5,0,0,0">
							<ToggleButton.Style>
								<Style TargetType="ToggleButton">
									<Setter Property="Focusable" Value="False" />
									<Setter Property="Width" Value="16" />
									<Setter Property="Height" Value="16" />
									<Setter Property="Template">
										<Setter.Value>
											<ControlTemplate TargetType="ToggleButton">
												<Border Background="Transparent" Height="16" Width="16"
														SnapsToDevicePixels="True">
													<Path x:Name="ExpandPath" Data="M 0 0 0 7 3.5 3.5 Z"
															Fill="{DynamicResource White}" Stroke="#FF838688"
															StrokeThickness="1" SnapsToDevicePixels="True"
															RenderOptions.EdgeMode="Aliased" VerticalAlignment="Center"
															HorizontalAlignment="Center">
														<Path.RenderTransform>
															<RotateTransform x:Name="expandPathTransform" Angle="0"
																	CenterY="3.5" CenterX="1" />
														</Path.RenderTransform>
													</Path>
													<VisualStateManager.VisualStateGroups>
														<VisualStateGroup x:Name="CommonStates">
															<VisualState Name="Normal">
																<Storyboard>
																	<DoubleAnimation Storyboard.TargetProperty="Angle"
																			Storyboard.TargetName="expandPathTransform"
																			To="0" Duration="0:0:0.3">
																		<DoubleAnimation.EasingFunction>
																			<QuarticEase />
																		</DoubleAnimation.EasingFunction>
																	</DoubleAnimation>
																</Storyboard>
															</VisualState>
															<VisualState Name="MouseOver">
																<Storyboard>
																	<DoubleAnimation Storyboard.TargetProperty="Angle"
																			Storyboard.TargetName="expandPathTransform"
																			To="0" Duration="0:0:0.3">
																		<DoubleAnimation.EasingFunction>
																			<QuarticEase />
																		</DoubleAnimation.EasingFunction>
																	</DoubleAnimation>
																</Storyboard>
															</VisualState>
															<VisualState Name="Checked">
																<Storyboard>
																	<DoubleAnimation Storyboard.TargetProperty="Angle"
																			Storyboard.TargetName="expandPathTransform"
																			To="45" Duration="0:0:0.3">
																		<DoubleAnimation.EasingFunction>
																			<QuarticEase />
																		</DoubleAnimation.EasingFunction>
																	</DoubleAnimation>
																</Storyboard>
															</VisualState>
															<VisualState Name="Disabled" />
														</VisualStateGroup>
													</VisualStateManager.VisualStateGroups>
												</Border>
												<ControlTemplate.Triggers>
													<Trigger Property="IsChecked" Value="True">
														<Setter Property="Fill" TargetName="ExpandPath"
																Value="#FF444444" />
														<Setter Property="Stroke" TargetName="ExpandPath"
																Value="#FF444444" />
													</Trigger>
													<Trigger Property="IsMouseOver" Value="True">
														<Setter Property="Stroke" TargetName="ExpandPath"
																Value="{DynamicResource TreeViewTriangleOver}" />
														<Setter Property="Fill" TargetName="ExpandPath"
																Value="{DynamicResource TreeViewTriangleOver}" />
													</Trigger>
													<MultiTrigger>
														<MultiTrigger.Conditions>
															<Condition Property="IsMouseOver" Value="True" />
															<Condition Property="IsChecked" Value="True" />
														</MultiTrigger.Conditions>
														<Setter Property="Stroke" TargetName="ExpandPath"
																Value="{DynamicResource TreeViewTriangleOver}" />
														<Setter Property="Fill" TargetName="ExpandPath"
																Value="{DynamicResource TreeViewTriangleOver}" />
													</MultiTrigger>
												</ControlTemplate.Triggers>
											</ControlTemplate>
										</Setter.Value>
									</Setter>
								</Style>
							</ToggleButton.Style>
						</ToggleButton>
						<ItemsPresenter x:Name="ItemsHost" Grid.ColumnSpan="2" Grid.Row="1">
							<ItemsPresenter.LayoutTransform>
								<ScaleTransform x:Name="itemsHostScale" CenterX="0.5" CenterY="0.5" ScaleX="1"
										ScaleY="0" />
							</ItemsPresenter.LayoutTransform>
						</ItemsPresenter>
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="CommonStates">
								<VisualState x:Name="Normal">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="itemsHostScale"
												Storyboard.TargetProperty="ScaleY">
											<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
												<EasingDoubleKeyFrame.EasingFunction>
													<QuarticEase />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="ItemsHost"
												Storyboard.TargetProperty="Opacity">
											<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
												<EasingDoubleKeyFrame.EasingFunction>
													<QuarticEase />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Expanded">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="itemsHostScale"
												Storyboard.TargetProperty="ScaleY">
											<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
												<EasingDoubleKeyFrame.EasingFunction>
													<QuarticEase />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="ItemsHost"
												Storyboard.TargetProperty="Opacity">
											<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
												<EasingDoubleKeyFrame.EasingFunction>
													<QuarticEase />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="HasItems" Value="False">
							<Setter Property="Visibility" TargetName="Expander" Value="Hidden" />
						</Trigger>
						<Trigger Property="HasItems" Value="True">
							<Setter Property="Padding" TargetName="PART_Header" Value="2,4,2,5" />
							<Setter Property="Background" TargetName="Bd" Value="#FFE1E1E1" />
						</Trigger>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="Background" TargetName="Bd"
									Value="{DynamicResource TreeViewItemMouseOver}" />
							<Setter Property="Foreground" Value="#FF262626" />
						</Trigger>
						<Trigger Property="IsSelected" Value="True">
							<Setter Property="Background" TargetName="Bd" Value="{DynamicResource TreeViewItemSelected}" />
							<Setter Property="Foreground" Value="#FF262626" />
						</Trigger>
						<!--<EventTrigger RoutedEvent="Loaded">
							<BeginStoryboard>
								<Storyboard>
									<ThicknessAnimation Storyboard.TargetProperty="Margin" From="0,-10,0,10"
											Duration="0:0:0.4" FillBehavior="Stop">
										<ThicknessAnimation.EasingFunction>
											<QuarticEase EasingMode="EaseOut" />
										</ThicknessAnimation.EasingFunction>
									</ThicknessAnimation>
									<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" Duration="0:0:0.4"
											FillBehavior="Stop">
										<DoubleAnimation.EasingFunction>
											<QuarticEase EasingMode="EaseOut" />
										</DoubleAnimation.EasingFunction>
									</DoubleAnimation>
								</Storyboard>
							</BeginStoryboard>
						</EventTrigger>-->
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="True" />
								<Condition Property="IsSelectionActive" Value="False" />
							</MultiTrigger.Conditions>
							<Setter Property="Background" TargetName="Bd" Value="#FFE1E1E1" />
							<Setter Property="Foreground" Value="#FF444444" />
						</MultiTrigger>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Foreground" Value="#FFBBBBBB" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>